
import 'package:favorcate/core/model/meal_model.dart';
import 'package:favorcate/core/viewmodel/favor_view_model.dart';
import 'package:favorcate/ui/pages/detail/meal_detail_content.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class JKMealDetailScreen extends StatelessWidget {

  static const String routeName = '/mealdetail';

  @override
  Widget build(BuildContext context) {

    final meal = ModalRoute.of(context).settings.arguments as JKHomeMealModel;
    return Scaffold(
      appBar: AppBar(
        title: Text('${meal.title}'),
      ),
      body: JKMealDetailContent(meal),
      floatingActionButton: Consumer<JKFavorViewModel>(
        builder: (ctx, favorVM, child) {
          return FloatingActionButton(
            backgroundColor: Colors.orange,
            child: Icon(
              favorVM.isFavor(meal) ? Icons.favorite : Icons.favorite_border,
              color: favorVM.isFavor(meal) ? Colors.red : Colors.black,
            ),
            onPressed: () {
              favorVM.handleMeal(meal);
            },
          );
        },
      )
    );
  }
}
